//
//  HEDataMangaeCell.m
//  HealthFamily
//
//  Created by LOOK on 2020/12/20.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEDataMangaeCell.h"
#import "HEDataManageModel.h"

@interface HEDataMangaeCell ()

@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *descLb;
@property (nonatomic, strong) UIImageView *leftView;
@property (nonatomic, strong) UIImageView *arrowView;

@end

@implementation HEDataMangaeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.qmui_borderPosition = QMUIViewBorderPositionBottom;
        self.qmui_borderWidth = 1;
        self.qmui_borderColor = CSplitLineColor;
        [self initUI];
    }
    return self;
}

- (void)initUI {
     
    _titleLb = [UILabel new];
    _titleLb.text = @"-";
    _titleLb.font = DYFont(17);
    _titleLb.textColor = CNavLightBlackColor;
    _titleLb.numberOfLines = 0;
    [self.contentView addSubview:_titleLb];
    
    
    _descLb = [[UILabel alloc] init];
    _descLb.text = @"-";
    _descLb.font = DYFont(17);
    _descLb.textColor = CNavDargGrayColor;
    _descLb.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_descLb];
    
    _leftView = [UIImageView new];
    _leftView.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_leftView];
    
    [_leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.width.height.offset(30);
    }];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(_leftView.mas_right).mas_offset(10);
        make.right.equalTo(_descLb.mas_left).mas_offset(-10);
        make.bottom.equalTo(self.contentView).mas_offset(-15);
    }];
     
    _arrowView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 8, 12)];
    _arrowView.contentMode = UIViewContentModeScaleAspectFill;
    _arrowView.image = IMAGE_NAMED(@"go_gray");
    [self.contentView addSubview:_arrowView];
    
    [_descLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(_arrowView.mas_left).mas_offset(-10);
        make.bottom.equalTo(self.contentView).mas_offset(-15);
//        make.left.mas_offset(180);
    }];
    
    [_arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.width.offset(8);
        make.height.offset(12);
    }];
}

- (void)configCellWithModel:(id)model {
    HEDataManageModel *item = (HEDataManageModel *)model;
    [_leftView sd_setImageWithURL:[NSURL URLWithString: item.icon] placeholderImage:IMAGE_NAMED(@"noImage")];
    _titleLb.text = item.check_name;
    _descLb.text = item.KMainValue;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
